using System;
using Fadd.Messaging;

namespace Fadd.IO.Consoles
{
    /// <summary>
    /// Packet used to transport objects to/from <see cref="BinaryChannel"/>
    /// </summary>
    [Serializable]
    public class ConsolePacket : IMessage
    {
        private readonly IMessage _wrappedMessage;

        /// <summary>
        /// Initializes a new instance of the <see cref="ConsolePacket"/> class.
        /// </summary>
        public ConsolePacket()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ConsolePacket"/> class.
        /// </summary>
        /// <param name="wrappedMessage">The wrapped message.</param>
        public ConsolePacket(IMessage wrappedMessage)
        {
            _wrappedMessage = wrappedMessage;
        }

        /// <summary>
        /// Gets the wrapped message.
        /// </summary>
        /// <value>The wrapped message.</value>
        public IMessage WrappedMessage
        {
            get { return _wrappedMessage; }
        }

        #region IMessage Members

        /// <summary>
        /// Gets if message can be queued or if it must be delivered real time or discarded if not possible.
        /// </summary>
        public bool IsQueuingAllowed
        {
            get { return true; }
        }

        #endregion
    }
}